package me.zk.practice1.s;

/**
 * @author zhangkai
 * @date 2023/7/17 10:32
 */
public class LS_Offer_63 {

    public int maxProfit(int[] prices) {
        int cost = Integer.MAX_VALUE;
        int pre = 0;

        for (int i = 0; i < prices.length; i++) {
            cost = Math.min(cost,prices[i]);
            pre =  Math.max(pre,prices[i] - cost);

        }
        return pre;
    }
}
